﻿using System;
using CustomerContactSystem.Core.Model;

namespace CustomerContactSystem.WebForms.Admin.Reps
{
    public partial class Create : BasePage {
        protected void Page_Load(object sender, EventArgs e) {
        }

        protected void CreateNewRepClick(object sender, EventArgs e) {
            var rep = new Rep
                {FirstName = FirstName.Text, SecondName = SecondName.Text, Email = Email.Text, IsActive = true};
            
            if (!IsValidObject(rep, ErrorMsg)) {
                return;
            }

            RepRepository.Add(rep);
            Response.Redirect("~/Admin/Reps/List.aspx#" + rep.Id);
        }        
    }
}